package com.lmabbe.tenant.controller;

import com.lmabbe.common.global.result.R;
import com.lmabbe.tenant.objects.dto.TenantInstallContextDTO;
import com.lmabbe.tenant.service.TenantInstallContextService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 租户安装
 *
 * @author lmabbe
 */
@Api(tags = "租户安装管理")
@RestController
@RequestMapping("tenantInstall")
@RequiredArgsConstructor
public class TenantInstallContextController {

    private final TenantInstallContextService tenantInstallContextService;

    /**
     * 构建租户安装信息
     *
     * @param contextDTO
     * @return
     */
    @Operation(summary = "构建租户")
    @PostMapping("build")
    public R build(@RequestBody TenantInstallContextDTO contextDTO) {
        tenantInstallContextService.build(contextDTO);
        return R.success();
    }

    /**
     * 构建租户&&发布
     *
     * @param contextDTO :
     * @return {@link R}
     * @date 2022/2/21 5:58 PM
     * @author liming
     */
    @Operation(summary = "构建租户&&发布")
    @PostMapping("buildAndPublish")
    public R buildAndPublish(@RequestBody TenantInstallContextDTO contextDTO) {
        tenantInstallContextService.buildAndPublish(contextDTO);
        return R.success();
    }
}
